package com.cykj.enterprise.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.stp.StpUtil;
import com.cykj.common.dto.ResponseDTO;
import com.cykj.common.entity.InterviewDetailDO;
import com.cykj.enterprise.service.ISelfService;
import com.github.pagehelper.PageHelper;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @BelongsProject: smart_recruit_backend
 * @BelongsPackage: com.cykj.enterprise.controller
 * @Author: 蔡张君逸
 * @CreateTime: 2025-08-21 08:40
 * @Description: TODO
 * @Version: 1.0
 */
@RestController
@CrossOrigin
@RequestMapping("self")
public class SelfController {
    @Autowired
    private ISelfService selfService;
//    聊天页面增加面试
    @Operation(summary = "聊天页面增加面试")
    @SaCheckLogin
    @GetMapping("addInterview")
    public ResponseDTO addInterviews(InterviewDetailDO interview) {
        System.err.println(interview.toString());
        return  selfService.addInterviews(interview);
    }
//    获取面试列表
    @Operation(summary = "获取面试列表")
    @Parameter(name = "pageNum",description = "页码",in = ParameterIn.QUERY)
    @Parameter(name = "pageSize",description = "页面大小",in = ParameterIn.QUERY)
    @SaCheckLogin
    @GetMapping("getInterviews")
    public ResponseDTO getInterviews(@RequestParam("pageNum") int pageNum, @RequestParam("pageSize")int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        int hrId = StpUtil.getLoginIdAsInt();
        return  selfService.getInterviews(hrId);
    }
    //    修改面试信息
    @Operation(summary = "修改面试信息")
    @Parameter(name = "bookingId",description = "面试id",in = ParameterIn.QUERY)
    @Parameter(name = "status",description = "修改的面试状态",in = ParameterIn.QUERY)
    @SaCheckLogin
    @GetMapping("updateInterviews")
    public ResponseDTO updateInterviews(@RequestParam(value = "bookingId",required = false)int bookingId,@RequestParam("status") int status) {
        System.err.println(status);
        return  selfService.updateInterviews(bookingId,status);
    }

    //    获取收藏人员
    @Operation(summary = "获取收藏人员")
    @Parameter(name = "pageNum",description = "页码",in = ParameterIn.QUERY)
    @Parameter(name = "pageSize",description = "页面大小",in = ParameterIn.QUERY)
    @SaCheckLogin
    @GetMapping("getCollectedUsers")
    public ResponseDTO getCollectedUsers(@RequestParam("pageNum") int pageNum, @RequestParam("pageSize")int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        int hrId = StpUtil.getLoginIdAsInt();
        return  selfService.getCollectedUsers(hrId);
    }
    //指定人员取消收藏
    @Operation(summary = "指定人员取消收藏")
    @Parameter(name = "userId",description = "用户id",in = ParameterIn.QUERY)
    @SaCheckLogin
    @GetMapping("delCollectedUser")
    public ResponseDTO delCollectedUser(@RequestParam("userId") int userId) {
        int hrId = StpUtil.getLoginIdAsInt();
        return selfService.delCollectedUser(userId,hrId);
    }
    //指定人员收藏
    @Operation(summary = "指定人员收藏")
    @Parameter(name = "userId",description = "用户id",in = ParameterIn.QUERY)
    @SaCheckLogin
    @GetMapping("collectUser")
    public ResponseDTO collectUser(@RequestParam("userId") int userId) {
        int hrId = StpUtil.getLoginIdAsInt();
        return selfService.collectUser(userId, hrId);
    }

    //    获取拉黑人员
    @Operation(summary = "获取拉黑人员")
    @Parameter(name = "pageNum",description = "页码",in = ParameterIn.QUERY)
    @Parameter(name = "pageSize",description = "页面大小",in = ParameterIn.QUERY)
    @SaCheckLogin
    @GetMapping("getBlockUsers")
    public ResponseDTO getBlockUsers(@RequestParam("pageNum") int pageNum, @RequestParam("pageSize")int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        int hrId = StpUtil.getLoginIdAsInt();
        return  selfService.getBlockUsers(hrId);
    }

    //指定人员取消拉黑
    @Operation(summary = "指定人员取消拉黑")
    @Parameter(name = "userId",description = "用户id",in = ParameterIn.QUERY)
    @SaCheckLogin
    @GetMapping("delBlockUser")
    public ResponseDTO delBlockUser(@RequestParam("userId") int userId) {
        int hrId = StpUtil.getLoginIdAsInt();
        return selfService.delBlockUser(userId, hrId);
    }

    //指定人员拉黑
    @Operation(summary = "指定人员拉黑")
    @Parameter(name = "userId",description = "用户id",in = ParameterIn.QUERY)
    @SaCheckLogin
    @GetMapping("blockUser")
    public ResponseDTO blockUser(@RequestParam("userId") int userId) {
        int hrId = StpUtil.getLoginIdAsInt();
        return selfService.blockUser(userId, hrId);
    }
}